<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>参数管理</title>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
	@import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../framework/uiutil.js"></script>
<script type="text/javascript" src="../framework/simpleCRUDUtil.js"></script>
<script type="text/javascript">
var SCU = new SimpleCrudUtil({
	c:"../bkgrd/saveParam.do",
	u:"../bkgrd/saveParam.do",
	r:"../bkgrd/getAllParam.do",
	d:"../bkgrd/deleteParam.do",
	grid:"grid",
	idName:"key"
	});
dojo.addOnLoad(function(){
	SCU.R();
});

function saveOrUpdateParam(){
	var key = dojo.byId("key").value;
	var value = dojo.byId("value").value;
	var description = dojo.byId("description").value;
	
	if(key == '' || value == ''){
		alert("请输入参数名称和值");
		return;
	}

	var model = {key:key,value:value,description:description}

	if(SCU.dupl(key)){
		if(!confirm("参数已存在，是否确认更新？"))return;
		SCU.U(model);
	}else{
		SCU.C(model);
	}
}

function startUpdateParam(){
	var item = SCU.getSelectedItem();
	if(item == null)return;
	
	dojo.byId("key").value = item["key"];
	dojo.byId("value").value = item["value"];
	dojo.byId("description").value = item["description"];
}

//删除参数
function deleteParam(){
	SCU.D();
}
</script>

<style type="text/css">
#grid{
	border:1px solid #333;
	width:80%;
	margin:10px;
	height:500px;
	font-size:0.9em;
}
</style>
</head>
<body class="tundra">


新增参数
<table width="100%">
<tr><td>参数名称</td><td><input type="text" dojoType="dijit.form.TextBox" id="key" size="30" trim="true" value=""/></td></tr>
<tr><td>参数值</td><td><input type="text" dojoType="dijit.form.TextBox" id="value" size="30" trim="true" value=""/></td></tr>
<tr><td>备注</td><td><input type="text" dojoType="dijit.form.TextBox" id="description" size="30" trim="true" value=""/></td></tr>
<tr><td colspan="2">

<button dojoType="dijit.form.Button" id="update" onclick="startUpdateParam()">修改参数</button>
<button dojoType="dijit.form.Button" id="query" onclick="saveOrUpdateParam()">保存参数</button>
<button dojoType="dijit.form.Button" id="delete" onclick="deleteParam()">删除参数</button>

</td></tr>
</table>

<table dojoType="dojox.grid.DataGrid" id="grid"  autoWidth="true">
 <thead>
	<tr>
	     <th field="key" width="200px">参数名</th>
	     <th field="value" width="200px">参数值</th>
	     <th field="description" width="300px">描述</th>
	</tr>
</thead>
</table>
</body>
</html>